package code.juc.stream;

import java.io.IOException;
import java.io.PipedWriter;

/**
 * 向管道中写入数据
 */
public class WriteData {

    public void writeMethod(PipedWriter out) {
        System.out.println("Write: ");
        try {
            for (int i = 1; i < 300; i++) {
                out.write(i + ", ");
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (out != null) {
                try {
                    out.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        System.out.println();
    }
}
